using Microsoft.SharePoint;

namespace PS.WebParts.Rollup.Core
{
    public class FieldInfo
    {
        public const string ExtPropKey = "SPFieldType";

        public FieldInfo()
        {
        }

        public FieldInfo(string internalName)
        {
            this.InternalName = internalName;
        }

        public FieldInfo(string internalName, string alias)
        {
            this.InternalName = internalName;
            this.alias = alias;
        }

        private string internalName;
        //private string origName;

        private string alias;
        private string match;
        private SPFieldType type;
        
        //public string GetOriginalName()
        //{
        //    return origName;
        //}

        public string GetSchemaName()
        {
            if (internalName.Contains("_x0020_"))
                return internalName.Replace("_x0020_", " ");
            else
                return internalName;
        }

        public string GetCamlName()
        {
            if (internalName.Contains(" "))
                return internalName.Replace(" ", "_x0020_");
            else
                return internalName;
        }

        public string InternalName
        {
            get { return internalName; }
            set {
                //origName = value;
                internalName = value; // != null ? value.Replace(" ", "_x0020_") : null;
            }
        }

        public string Alias
        {
            get { return alias; }
            set { alias = value; }
        }


        public string Match
        {
            get { return match; }
            set { match = value; }
        }

        public SPFieldType Type
        {
            get { return type; }
            set { type = value; }
        }
    }
}
